import type { Router } from 'vue-router';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';

export function setupRouterGuard(router: Router) {
  startLoading(router);
  endLoading(router);
}

function startLoading(router: Router) {
  router.beforeEach(() => {
    NProgress.start();
  });
}

function endLoading(router: Router) {
  router.afterEach(() => {
    NProgress.done();
  });
}
